package com.rong.text;

import com.rong.dao.zhMapper;
import com.rong.pojo.zh;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

public class test01 {
    public static void main(String[] args) {
        try {
            String resource = "mybatis-config.xml";
            InputStream inputStream = Resources.getResourceAsStream(resource);
            SqlSessionFactory sqlSessionFactory =
                    new SqlSessionFactoryBuilder().build(inputStream);
            //           核心类，执行增删改查操作的，类似于jdbc中的satetment
            SqlSession session= sqlSessionFactory.openSession();
            //使用接口方式查询
            zhMapper mapper=session.getMapper(zhMapper.class);
            zh user= mapper.selectByPrimaryKey((long) 3);
            System.out.println(user);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    }

